package HashPackage2;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

/**
 * @author Lzm
 * @version 1.0
 */
public class isAnagram_ {

  public boolean isAnagram(String s, String t) {
    if (s == null || t == null){
      return false;
    }
    if (s.equals(t)){
      return true;
    }
    if (s.length() != t.length()){
      return false;
    }
    int[] hashTable = new int[s.length()];
    for (int i = 0 ; i < hashTable.length ; i ++){
      hashTable[s.charAt(i) % s.length()]++;
      hashTable[t.charAt(i) % s.length()]--;
    }
    for (int ele : hashTable) {
      if (ele != 0){
        return false;
      }
    }
    return true;
  }
}
